package com.gaoyi.crm.control;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.BindingAdapter;

import com.gaoyi.crm.R;
import com.gaoyi.crm.databinding.ViewShowBinding;

public class ShowView extends BaseView<ViewShowBinding> {
    public ShowView(@NonNull Context context) {
        super(context);
    }

    public ShowView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ShowView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public ShowView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void initView(TypedArray ta) {
        String title = ta.getString(R.styleable.ShowView_show_title);
        mBinding.tvTitle.setText(String.format("%s：", title));
    }

    @Override
    protected ViewShowBinding getViewBinding() {
        return ViewShowBinding.inflate(LayoutInflater.from(mContext));
    }

    @Override
    protected int[] getAttrs() {
        return R.styleable.ShowView;
    }
//
//    public void setContent(String content) {
//        mBinding.tvContent.setText(content);
//    }

    @BindingAdapter("setContent")
    public static void setContent(ShowView v, String text) {
        v.mBinding.tvContent.setText(text == null?"":text);
    }
}
